home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase v5.5 / UTILS.PAK / GETFIELD.WFM < prev    next >
Encoding:
Text File  |  1995-07-18  |  23.6 KB  |  785 lines

  1. *******************************************************************************
  2. * PROGRAM:     Getfield.wfm
  3. *
  4. * WRITTEN BY:  Borland Samples Group
  5. *
  6. * DATE:        3/95
  7. *
  8. * UPDATED:     7/95
  9. *
  10. * REVISION:    $Revision:   1.18  $
  11. *
  12. * VERSION:     Visual dBASE
  13. *
  14. * DESCRIPTION: This is a tool for selecting fields from a list of tables.
  15. *
  16. * PARAMETERS:  None
  17. *
  18. * CALLS:       Buttons.cc    (Custom Controls file)
  19. *
  20. * USAGE:       DO Getfield.wfm
  21. *
  22. ********************************************************************************
  23. #include <Messdlg.h>
  24.  
  25. *** Field restrictions
  26. #define MEMO_BINARY_OLE        "M, B, O"
  27. #define PDOX_FIELD_DELIM       ":"
  28.  
  29. * GetField.wfm
  30. * (Take 2)
  31.  
  32. create session
  33. set talk off
  34. set exact off
  35. set fullpath off
  36.  
  37.  
  38. ** END HEADER -- do not remove this line*
  39. * Generated on 04/10/95
  40. *
  41. parameter bModal
  42. local f
  43. f = new GETFIELDFORM()
  44. if (bModal)
  45.    f.mdi = .F. && ensure not MDI
  46.    f.ReadModal()
  47. else
  48.    f.Open()
  49. endif
  50. CLASS GETFIELDFORM OF FORM
  51.    set procedure to &_dbwinhome.custom\Buttons.cc additive
  52.    this.OnClose = CLASS::FORM_ONCLOSE
  53.    this.Text = "Select Fields"
  54.    this.Left = 5
  55.    this.ColorNormal = "N/BTNFACE"
  56.    this.Top = 1
  57.    this.TopMost = .F.
  58.    this.PageNo = 1
  59.    this.Height = 13.8232
  60.    this.Width = 73.666
  61.    this.OnOpen = CLASS::FORM_ONOPEN
  62.  
  63.    DEFINE RECTANGLE ALLRECT OF THIS;
  64.        PROPERTY;
  65.          Text "",;
  66.          Left 0.5,;
  67.          ColorNormal "BTNTEXT/BTNFACE",;
  68.          Top 1.1758,;
  69.          PageNo 1,;
  70.          Border .T.,;
  71.          Height 10.8242,;
  72.          Width 73.166
  73.  
  74.    DEFINE RECTANGLE TABLESRECT OF THIS;
  75.        PROPERTY;
  76.          Text "",;
  77.          Left 1.1973,;
  78.          ColorNormal "BTNTEXT/gb",;
  79.          Top 3.5293,;
  80.          PageNo 1,;
  81.          Border .T.,;
  82.          Height 8.2939,;
  83.          Width 21.3027
  84.  
  85.    DEFINE TEXT TABLESTEXT OF THIS;
  86.        PROPERTY;
  87.          Text "Available Tables:",;
  88.          Left 1.5,;
  89.          ColorNormal "w/gb",;
  90.          Top 3.8223,;
  91.          PageNo 1,;
  92.          Border .F.,;
  93.          Height 0.707,;
  94.          FontSize 9,;
  95.          Width 17.166
  96.  
  97.    DEFINE LISTBOX TABLELIST OF THIS;
  98.        PROPERTY;
  99.          Sorted .T.,;
  100.          DataSource "TABLES",;
  101.          FontBold .F.,;
  102.          Left 1.75,;
  103.          ColorNormal "n/w+",;
  104.          ID 100,;
  105.          Top 4.5879,;
  106.          PageNo 1,;
  107.          OnSelChange CLASS::TABLELIST_ONSELCHANGE,;
  108.          Height 6.8232,;
  109.          Width 20.083,;
  110.          ColorHighLight "w+/w"
  111.  
  112.    DEFINE RECTANGLE FIELDRECT OF THIS;
  113.        PROPERTY;
  114.          FontBold .F.,;
  115.          Text "",;
  116.          Left 25.3311,;
  117.          ColorNormal "gb/gb",;
  118.          Top 3.5293,;
  119.          FontItalic .T.,;
  120.          PageNo 1,;
  121.          FontName "Times New Roman",;
  122.          Border .T.,;
  123.          Height 8.2939,;
  124.          FontSize 10,;
  125.          Width 47.335
  126.  
  127.    DEFINE TEXT AVAILABLETEXT OF THIS;
  128.        PROPERTY;
  129.          Text "Available Fields:",;
  130.          Left 26.5,;
  131.          ColorNormal "w/gb",;
  132.          Top 3.8223,;
  133.          PageNo 1,;
  134.          Border .F.,;
  135.          Height 0.707,;
  136.          FontSize 9,;
  137.          Width 19.166
  138.  
  139.    DEFINE LISTBOX AVAILABLELIST OF THIS;
  140.        PROPERTY;
  141.          Sorted .T.,;
  142.          OnLeftDblClick CLASS::SELECTONEFIELDPUSH_ONCLICK,;
  143.          FontBold .F.,;
  144.          Left 26.3311,;
  145.          ColorNormal "b/w+",;
  146.          ID 101,;
  147.          Top 4.5879,;
  148.          PageNo 1,;
  149.          Height 6.8232,;
  150.          Width 20.002,;
  151.          ColorHighLight "w+/w"
  152.  
  153.    DEFINE PUSHBUTTON SELECTONEFIELDPUSH OF THIS;
  154.        PROPERTY;
  155.          Text ">",;
  156.          Left 47,;
  157.          ColorNormal "BtnText/BtnFace",;
  158.          Top 4.5879,;
  159.          PageNo 1,;
  160.          OnClick CLASS::SELECTONEFIELDPUSH_ONCLICK,;
  161.          Default .T.,;
  162.          Group .T.,;
  163.          Height 1.2939,;
  164.          Width 4
  165.  
  166.    DEFINE PUSHBUTTON SELECTALLFIELDPUSH OF THIS;
  167.        PROPERTY;
  168.          Text ">>",;
  169.          Left 47,;
  170.          ColorNormal "BtnText/BtnFace",;
  171.          Top 6,;
  172.          PageNo 1,;
  173.          OnClick CLASS::SELECTALLFIELDPUSH_ONCLICK,;
  174.          Group .T.,;
  175.          Height 1.2939,;
  176.          Width 4
  177.  
  178.    DEFINE PUSHBUTTON UNSELECTONEFIELDPUSH OF THIS;
  179.        PROPERTY;
  180.          Text "<",;
  181.          Left 47,;
  182.          ColorNormal "BtnText/BtnFace",;
  183.          Top 8.7051,;
  184.          PageNo 1,;
  185.          OnClick CLASS::UNSELECTONEFIELDPUSH_ONCLICK,;
  186.          Group .T.,;
  187.          Height 1.2949,;
  188.          Width 4
  189.  
  190.    DEFINE PUSHBUTTON UNSELECTALLFIELDPUSH OF THIS;
  191.        PROPERTY;
  192.          Text "<<",;
  193.          Left 47,;
  194.          ColorNormal "BtnText/BtnFace",;
  195.          Top 10.1758,;
  196.          PageNo 1,;
  197.          OnClick CLASS::UNSELECTALLFIELDPUSH_ONCLICK,;
  198.          Group .T.,;
  199.          Height 1.2939,;
  200.          Width 4
  201.  
  202.    DEFINE TEXT SELECTEDTEXT OF THIS;
  203.        PROPERTY;
  204.          Text "Selected Fields:",;
  205.          Left 52,;
  206.          ColorNormal "w+/gb",;
  207.          Top 3.8223,;
  208.          PageNo 1,;
  209.          Border .F.,;
  210.          Height 0.7656,;
  211.          FontSize 9,;
  212.          Width 19.166
  213.  
  214.    DEFINE LISTBOX SELECTEDLIST OF THIS;
  215.        PROPERTY;
  216.          Sorted .T.,;
  217.          OnLeftDblClick CLASS::UNSELECTONEFIELDPUSH_ONCLICK,;
  218.          FontBold .F.,;
  219.          Left 52,;
  220.          ColorNormal "r/w+",;
  221.          ID 101,;
  222.          Top 4.5879,;
  223.          PageNo 1,;
  224.          Height 6.8232,;
  225.          Width 20,;
  226.          ColorHighLight "w+/w"
  227.  
  228.    DEFINE TEXT ARROWTEXT OF THIS;
  229.        PROPERTY;
  230.          Text "=>",;
  231.          Left 22.8311,;
  232.          ColorNormal "BtnText/BtnFace",;
  233.          Top 7.1758,;
  234.          Alignment 4,;
  235.          PageNo 1,;
  236.          FontName "Arial",;
  237.          Border .F.,;
  238.          Height 1.1182,;
  239.          FontSize 11,;
  240.          Width 2.002
  241.  
  242.    DEFINE PUSHBUTTON ALIASBUTTON OF THIS;
  243.        PROPERTY;
  244.          FontBold .F.,;
  245.          Text "Aliases ...",;
  246.          Left 15.1973,;
  247.          ColorNormal "BtnText/BtnFace",;
  248.          Top 12.2979,;
  249.          PageNo 1,;
  250.          Enabled .F.,;
  251.          Group .T.,;
  252.          Height 1.5254,;
  253.          Width 14.1357
  254.  
  255.    DEFINE OKBUTTON OKBUTTON1 OF THIS;
  256.        PROPERTY;
  257.          FontBold .F.,;
  258.          Left 30,;
  259.          Top 12.2979,;
  260.          OnClick {;form.Close()},;
  261.          Group .T.,;
  262.          Height 1.5254,;
  263.          Width 14.166
  264.  
  265.    DEFINE CANCELBUTTON CANCELBUTTON1 OF THIS;
  266.        PROPERTY;
  267.          FontBold .F.,;
  268.          Left 45,;
  269.          Top 12.2979,;
  270.          Group .T.,;
  271.          Height 1.5254,;
  272.          Width 14.166
  273.  
  274.    DEFINE HELPBUTTON HELPBUTTON1 OF THIS;
  275.        PROPERTY;
  276.          FontBold .F.,;
  277.          Enabled .F.,;
  278.          Left 59.5,;
  279.          Top 12.2979,;
  280.          Group .T.,;
  281.          Height 1.5254,;
  282.          Width 14.166
  283.  
  284.    DEFINE TEXT DIRECTORYTEXT OF THIS;
  285.        PROPERTY;
  286.          FontBold .F.,;
  287.          Text "",;
  288.          Left 0.5,;
  289.          ColorNormal "W+/BTNFACE",;
  290.          Top 0.1973,;
  291.          PageNo 1,;
  292.          Border .F.,;
  293.          Height 0.8975,;
  294.          Width 73
  295.  
  296.    DEFINE RECTANGLE RADIORECT OF THIS;
  297.        PROPERTY;
  298.          Text "",;
  299.          Left 1,;
  300.          ColorNormal "BTNTEXT/BTNFACE",;
  301.          Top 1.2998,;
  302.          PageNo 1,;
  303.          Border .T.,;
  304.          Height 2.1699,;
  305.          Width 72.166
  306.  
  307.    DEFINE RADIOBUTTON DATABASERADIO OF THIS;
  308.        PROPERTY;
  309.          FontBold .F.,;
  310.          Text "Tables from D&atabase",;
  311.          Left 16.5,;
  312.          ColorNormal "B/BTNFACE",;
  313.          Top 2.4199,;
  314.          PageNo 1,;
  315.          OnChange CLASS::DATABASERADIO_ONCHANGE,;
  316.          Group .T.,;
  317.          Height 0.85,;
  318.          Width 20.666,;
  319.          Value .F.
  320.  
  321.    DEFINE RADIOBUTTON DIRRADIO OF THIS;
  322.        PROPERTY;
  323.          FontBold .F.,;
  324.          Text "Tables from D&irectory",;
  325.          Left 16.5,;
  326.          ColorNormal "B/BTNFACE",;
  327.          Top 1.5,;
  328.          PageNo 1,;
  329.          OnChange CLASS::DIRRADIO_ONCHANGE,;
  330.          Group .F.,;
  331.          Height 0.85,;
  332.          Width 19.333,;
  333.          Value .T.
  334.  
  335.    DEFINE PUSHBUTTON DIRECTORYBUTTON OF THIS;
  336.        PROPERTY;
  337.          FontBold .F.,;
  338.          Text "&Directory",;
  339.          Left 1.5,;
  340.          ColorNormal "BtnText/BtnFace",;
  341.          Top 1.6992,;
  342.          PageNo 1,;
  343.          OnClick CLASS::DIRECTORYBUTTON_ONCLICK,;
  344.          UpBitmap "RESOURCE #137",;
  345.          Group .T.,;
  346.          Height 1.5352,;
  347.          Width 14.166
  348.  
  349.    DEFINE PUSHBUTTON DATABASEBUTTON OF THIS;
  350.        PROPERTY;
  351.          FontBold .F.,;
  352.          Visible .F.,;
  353.          Text "&Login...",;
  354.          Left 1.5,;
  355.          ColorNormal "BtnText/BtnFace",;
  356.          Top 1.6992,;
  357.          PageNo 1,;
  358.          OnClick CLASS::DATABASEBUTTON_ONCLICK,;
  359.          UpBitmap "RESOURCE #137",;
  360.          Group .T.,;
  361.          Height 1.5352,;
  362.          Width 14.166
  363.  
  364.    DEFINE ENTRYFIELD DATABASEENTRY OF THIS;
  365.        PROPERTY;
  366.          Function "!",;
  367.          Left 40.5,;
  368.          ColorNormal "WINDOWTEXT/W",;
  369.          Top 2.31,;
  370.          PageNo 1,;
  371.          Function "!S25",;
  372.          Enabled .F.,;
  373.          Border .T.,;
  374.          Height 1.0029,;
  375.          Width 32,;
  376.          Value "",;
  377.          ColorHighLight "WINDOWTEXT/WINDOW"
  378.  
  379.    procedure FORM_OnOpen
  380.    ****************************************************************************
  381.  
  382.    set procedure to &_dbwinhome.utils\Sql.wfm additive    && Procedure file
  383.  
  384.  
  385.    form.saveExact = set("exact")
  386.    set exact off
  387.  
  388.  
  389.    * Arrays for storing fields from selected tables -- all available and
  390.    * those specifically selected.
  391.    form.availableAr = new array(0)
  392.    form.selectedAr = new array(0)
  393.  
  394.    form.tableNamesAr = new array(0)
  395.  
  396.    form.availableList.dataSource = "array form.availableAr"
  397.    form.selectedList.dataSource = "array form.selectedAr"
  398.  
  399.    form.tableList.curSel = 1            && Immediately show fields of first table
  400.  
  401.    form.allFields = .F.                 && Indicates if all fields were selected
  402.    form.tablesFromDatabase = .F.        && Indicates if tables are from database
  403.  
  404.    form.saveArea = workarea()           && Save workarea
  405.    form.tempArea = select()             && Temporary workarea
  406.    form.saveDir = setto("directory")    && Save directory, in case it changes
  407.  
  408.    if empty(setto("database"))
  409.       form.dirRadio.SetFocus()
  410.       form.directoryText.text = lower(form.saveDir)
  411.       form.serverName = ""
  412.    else
  413.       form.databaseRadio.SetFocus()
  414.       form.databaseButton.OnClick()
  415.       form.serverName = setto("database")
  416.    endif
  417.    form.tableList.OnSelChange()
  418.  
  419.  
  420.    ****************************************************************************
  421.  
  422.    procedure FORM_OnClose
  423.    ****************************************************************************
  424.    private i, saveArea, tempArea, afterPeriod, curDir, saveDir, saveExact,;
  425.            serverName, selectedArSize, tableNamesArSize
  426.  
  427.    selectedArSize = form.selectedAr.size
  428.    tableNamesArSize = form.tableNamesAr.size
  429.  
  430.    form.selectedAr.Sort()
  431.    if form.tablesFromDatabase           && Tables from database
  432.       serverName = rtrim(form.directoryText.text)
  433.       form.serverName = serverName
  434.       for i = 1 to selectedArSize
  435.          && Surround field name with double quotes (some servers don't like ')
  436.          form.selectedAr[i] = SurroundLastWordByQuotes(form.selectedAr[i])
  437.       next i
  438.       for i = 1 to tableNamesArSize
  439.          form.tableNamesAr[i] = SurroundByQuotes(form.tableNamesAr[i])
  440.       next i
  441.    else                                 && Tables from directory
  442.       * Uppercase selected table and field arrays
  443.       for i = 1 to selectedArSize
  444.          && Surround field name with double quotes
  445.          form.selectedAr[i] = upper(;
  446.                                SurroundLastWordByQuotes(form.selectedAr[i]))
  447.       next i
  448.       *** Local SQL doesn't allow drives in table names w/o quotes
  449.       curDir = setto("directory") + "\"
  450.       for i = 1 to form.tableNamesAr.size
  451.          form.tableNamesAr[i] = upper(;
  452.                                  SurroundByQuotes(curDir + form.tableNamesAr[i]))
  453.       next i
  454.    endif
  455.  
  456.    form.tableNamesAr.Sort()
  457.  
  458.    close procedure &_dbwinhome.custom\Buttons.cc, &_dbwinhome.utils\Sql.wfm
  459.  
  460.    tempArea = str(form.tempArea)
  461.    saveArea = str(form.saveArea)
  462.    saveDir = form.saveDir
  463.    saveExact = form.saveExact
  464.    use in &tempArea
  465.    select &saveArea
  466.    cd &saveDir
  467.    set exact &saveExact
  468.  
  469.  
  470.    ****************************************************************************
  471.  
  472.    procedure SelectOneFieldPush_OnClick
  473.    ****************************************************************************
  474.    private tableName, markedField, lastSelectedField, saveExact, saveCurSel
  475.  
  476.    saveCurSel = form.availableList.curSel
  477.    * if available fields exist, and one is marked
  478.    if (form.availableAr.size > 0) .and. (form.availableList.curSel > 0)
  479.       * Once a single field button is pressed, allFields is .F.
  480.       form.allFields = .F.
  481.  
  482.       * Add currently marked item in "available" list to "selected" list
  483.       markedField = form.availableList.selected()
  484.       form.selectedAr.Add(markedField)
  485.       if form.availableAr.size > 1
  486.          form.availableAr.Delete(form.availableList.curSel)  && No longer available
  487.          form.availableAr.Resize(form.availableAr.size - 1)  && Resize available ar
  488.       else
  489.          form.availableAr = new array(0)
  490.          form.availableList.dataSource = "array form.availableAr"
  491.          form.selectedList.curSel = 1   && Highlight first selected field
  492.       endif
  493.  
  494.       * Add Table name to list of selected tables
  495.       lastSelectedField = form.selectedAr[form.selectedAr.size]
  496.       tableName = form.tableList.Selected()  &&substr(lastSelectedField, 1, rat(".", lastSelectedField) -1)
  497.       saveExact = set("exact")
  498.       set exact on
  499.       if form.tableNamesAr.Scan(tableName) = 0  && Add table to array of tables
  500.          form.tableNamesAr.Add(tableName)
  501.       endif
  502.       set exact &saveExact
  503.  
  504.       form.UpdateListboxes()
  505.       * Don't want curSel to ever = 0
  506.       form.availableList.curSel = max(1, min(saveCurSel, form.availableAr.size))
  507.       form.selectedList.curSel = form.selectedAr.Scan(markedField)
  508.       if type("form.oneTable") <> "U"
  509.          CLASS::CheckSelected(form.tableList, form.selectedList)
  510.       endif
  511.    endif
  512.  
  513.  
  514.    ****************************************************************************
  515.  
  516.    procedure SelectAllFieldPush_OnClick
  517.    ****************************************************************************
  518.    local availableSize, prevSelectedSize, selectedTable, tableName
  519.  
  520.    if (form.availableAr.size > 0)             && If some fields are available
  521.       * Indicate that all fields have been selected
  522.       form.allFields = .T.
  523.  
  524.       availableSize = form.availableAr.size
  525.       prevSelectedSize = form.selectedAr.size
  526.  
  527.       * Copy all elements from "available" to "selected" array
  528.       form.selectedAr.Resize(prevSelectedSize + availableSize)
  529.       acopy(form.availableAr, form.selectedAr, 1, availableSize, prevSelectedSize + 1)
  530.  
  531.       * Delete all elements from "available" array
  532.       form.availableAr = new array(0)
  533.  
  534.       * Add Table names to list of selected tables
  535.       selectedTable = form.tableList.Selected()
  536.       tableName = selectedTable
  537.  
  538.       if form.tableNamesAr.Scan(tableName) = 0
  539.          form.tableNamesAr.Add(tableName)
  540.       endif
  541.  
  542.       form.UpdateListboxes()
  543.       form.selectedList.curSel = 1      && Highlight first selected field
  544.       if type("form.oneTable") <> "U"
  545.          CLASS::CheckSelected(form.tableList, form.selectedList)
  546.       endif
  547.    endif
  548.  
  549.    ****************************************************************************
  550.  
  551.    procedure UnSelectOneFieldPush_OnClick
  552.    ****************************************************************************
  553.    private tableName, selectedField, selectedTable, fieldAlias, saveCurSel
  554.  
  555.    saveCurSel = form.selectedList.curSel
  556.    if (form.selectedAr.size > 0) .and. (form.selectedList.curSel > 0)
  557.       * Once a single field button is pressed, allFields is .F.
  558.       form.allFields = .F.
  559.  
  560.       selectedField = form.selectedList.Selected()
  561.       selectedTable = form.tableList.Selected()
  562.       tableName = selectedTable
  563.       fieldAlias = substr(selectedField, 1, at(".", selectedField) -1)
  564.  
  565.       if tableName = fieldAlias &&= tableName         && unmark field from cur. table
  566.          form.availableAr.Add(selectedField)
  567.       endif
  568.       if form.selectedAr.size > 1
  569.          form.selectedAr.Delete(form.selectedList.curSel)
  570.          form.selectedAr.Resize(form.selectedAr.size - 1)
  571.       else
  572.          form.selectedAr = new array(0)
  573.          form.selectedList.datasource = "array form.selectedAr"
  574.          form.availableList.curSel = 1  && Highlight first available field
  575.       endif
  576.  
  577.       * If no more fields selected from this table, delete table from array of tables
  578.       if form.selectedAr.Scan(fieldAlias) = 0 .or. form.selectedList.Count() =  0
  579.          * Delete table name from array of tables
  580.          form.tableNamesAr.Delete(form.tableNamesAr.Scan(fieldAlias))
  581.          if form.tableNamesAr.size > 1
  582.             form.tableNamesAr.Resize(form.tableNamesAr.size - 1)
  583.          else
  584.             form.tableNamesAr = new array(0)
  585.          endif
  586.       endif
  587.  
  588.       form.UpdateListboxes()
  589.       form.selectedList.curSel = max(1, min(saveCurSel, form.selectedAr.size))
  590.       form.availableList.curSel = form.availableAr.Scan(selectedField)
  591.       if type("form.oneTable") <> "U"
  592.          CLASS::CheckSelected(form.tableList, form.selectedList)
  593.       endif
  594.    endif
  595.  
  596.    ****************************************************************************
  597.  
  598.    Procedure UnSelectAllFieldPush_OnClick
  599.    ****************************************************************************
  600.  
  601.    form.allFields = .F.                 && all fields have not been selected
  602.  
  603.    form.selectedAr = new array(0)       && Clear seleted field array
  604.  
  605.    form.tableNamesAr = new array(0)     && Clear table names array
  606.    form.tableList.OnSelChange()         && Show fields of current table
  607.  
  608.    form.UpdateListboxes()
  609.    form.availableList.curSel = 1        && Highlight first available field
  610.    if type("form.oneTable") <> "U"
  611.       CLASS::CheckSelected(form.tableList, form.selectedList)
  612.    endif
  613.  
  614.  
  615.    ****************************************************************************
  616.  
  617.    Procedure TABLELIST_OnSelChange
  618.    ****************************************************************************
  619.    private i, selAlias, fieldName, fullFieldName, tempArea
  620.  
  621.    tempArea = str(form.tempArea)
  622.    use (this.selected()) in &tempArea   && Open table so its structure visible from availableList
  623.    select &tempArea
  624.    if form.tablesFromDatabase           && Table from database
  625.       selAlias = this.selected()
  626.    else                                 && Table from directory
  627.       selAlias = lower(StripDrive(StripExtension(dbf())))
  628.    endif
  629.  
  630.    form.availableAr = new array(0)
  631.    for i = 1 to fcount()
  632.       fieldName = field(i)
  633.       * Check if Paradox table, and remove delimiters
  634.       if left(fieldName, 1) = PDOX_FIELD_DELIM
  635.          fieldName = substr(fieldName, 2, len(fieldName) - 2)
  636.       endif
  637.       * Create correct <alias>.<field> string
  638.       if form.tablesFromDatabase
  639.          fullFieldName = selAlias + "." + fieldName        && field name in original case
  640.       else
  641.          fullFieldName = selAlias + "." + lower(fieldName) && lower cased field name
  642.       endif
  643.       * Add field to available array, if it is not a BLOB
  644.       if form.selectedAr.Scan(fullFieldName) = 0 .and.;
  645.          (.not. type(fieldName) $ MEMO_BINARY_OLE)  && Make sure field type is
  646.                                                     && not MEMO, OLE, or BINARY
  647.          form.availableAr.Add(fullFieldName)
  648.       endif
  649.    next i
  650.  
  651.    form.UpdateListboxes()
  652.    form.availableList.curSel = 1
  653.  
  654.  
  655.    ****************************************************************************
  656.    Procedure CheckSelected(tableList, selectedList)
  657.  
  658.    * This procedure is called only if the form property oneTable is set
  659.    * in the calling form.  It disables the tables list if a field
  660.    * has been selected -- to make sure only fields from one table are
  661.    * selected in this form.
  662.    ****************************************************************************
  663.    private selCount
  664.  
  665.    selCount = selectedList.Count()
  666.  
  667.    if selCount > 0 .and. tableList.enabled = .T.
  668.       tableList.enabled = .F.
  669.    else if selCount = 0
  670.       tableList.enabled = .T.
  671.    endif
  672.  
  673.  
  674.  
  675.    ****************************************************************************
  676.  
  677.    Procedure UpdateListboxes
  678.    ****************************************************************************
  679.  
  680.    *** Sorted property on listboxes doesn't sort array datasources
  681.    form.availableAr.Sort()
  682.    form.selectedAr.Sort()
  683.  
  684.    form.availableList.dataSource = "array form.availableAr"
  685.    form.selectedList.dataSource = "array form.selectedAr"
  686.  
  687.  
  688.    form.selectOneFieldPush.enabled = .T.
  689.    form.selectAllFieldPush.enabled = .T.
  690.    form.unSelectOneFieldPush.enabled = .T.
  691.    form.unSelectAllFieldPush.enabled = .T.
  692.  
  693.    * Only buttons capable of some action are made available
  694.    if form.selectedAr.size = 0
  695.       form.unSelectOneFieldPush.enabled = .F.
  696.       form.unSelectAllFieldPush.enabled = .F.
  697.    else if form.availableAr.size = 0
  698.       form.selectOneFieldPush.enabled = .F.
  699.       form.selectAllFieldPush.enabled = .F.
  700.    endif
  701.  
  702.  
  703.    show object form.availableList
  704.    show object form.selectedList
  705.    show object form.selectOneFieldPush
  706.    show object form.selectAllFieldPush
  707.    show object form.unSelectOneFieldPush
  708.    show object form.unSelectAllFieldPush
  709.  
  710.  
  711.    ****************************************************************************
  712.  
  713.    Procedure DIRECTORYBUTTON_OnClick
  714.    ****************************************************************************
  715.    private tablesDir
  716.  
  717.    tablesDir = getdirectory()
  718.    if .not. empty(tablesDir)
  719.       cd &tablesDir
  720.    endif
  721.    form.tableList.dataSource = "TABLES"
  722.    form.directoryText.text = lower(tablesDir)
  723.  
  724.    form.tableList.curSel = 1
  725.    form.tableList.OnSelChange()
  726.  
  727.  
  728.    *******************************************************************************
  729.    Procedure DATABASEBUTTON_OnClick
  730.    *******************************************************************************
  731.    private databaseName
  732.  
  733.    databaseName = form.databaseEntry.value
  734.    on error HandleDatabaseError()
  735.    open database &databaseName
  736.    set database to &databaseName
  737.    databaseName = setto("database")
  738.    if .not. empty(databaseName)
  739.       form.directoryText.text = databaseName
  740.       show object form.tableList
  741.       show object form.availableList
  742.       show object form.selectedList
  743.       form.tableList.OnSelChange()
  744.       show object form.tableList
  745.       show object form.availableList
  746.       show object form.selectedList
  747.       form.tableList.SetFocus()
  748.    else
  749.       form.databaseEntry.value = ""
  750.       form.dirRadio.SetFocus()
  751.    endif
  752.    on error
  753.  
  754.  
  755.    ****************************************************************************
  756.  
  757.    Procedure DIRRADIO_OnChange
  758.    ****************************************************************************
  759.  
  760.    form.directoryButton.visible = this.Value
  761.    if this.Value
  762.       form.databaseEntry.value = ""
  763.       show object form.databaseEntry
  764.    endif
  765.    form.databaseEntry.enabled = .not. this.Value
  766.    form.tablesFromDatabase = .not. this.Value
  767.  
  768.  
  769.    ****************************************************************************
  770.  
  771.    Procedure DATABASERADIO_OnChange
  772.    ****************************************************************************
  773.  
  774.    form.databaseButton.visible = this.Value
  775.    form.databaseEntry.enabled = this.Value
  776.    if this.value
  777.       form.databaseEntry.SetFocus()
  778.    endif
  779.    form.tablesFromDatabase = this.Value
  780.  
  781.  
  782.  
  783. ENDCLASS
  784.  
  785.